



<div class="x-body">
    <form class="layui-form form_single" id="form" action="{:url()}" method="post">
        <div class="layui-form-item">
            <label for="username" class="layui-form-label">
                <span class="x-red">*</span>标题
            </label>
            <div class="layui-input-block">
                <input type="text" id="username" name="name" onchange="this.value=this.value.substring(0, 30)" onkeydown="this.value=this.value.substring(0, 30)" onkeyup="this.value=this.value.substring(0, 30)" required="" lay-verify="required"
                       autocomplete="off"  value="{$info['name']|default=''}" class="layui-input">
            </div>
            <div style="color: red !important;" class="layui-form-mid layui-word-aux">
                （限制30字符）
            </div>
        </div>

        <div class="layui-form-item">
            <label for="L_pass" class="layui-form-label">
             排序
            </label>
            <div class="layui-input-block">
                <input type="number" id="L_pass" name="sort"
                       autocomplete="off" class="layui-input"  value="{$info['sort']|default=''}">
            </div>
            <div class="layui-form-mid layui-word-aux">
                (排序越大，顺序越前,默认0)
            </div>
        </div>

        <div class="layui-form-item">
            <label for="describe" class="layui-form-label">
               描述
            </label>
            <div class="layui-input-block">
                <textarea id="describe" class="layui-textarea" name="describe" maxlength="200" onchange="this.value=this.value.substring(0, 200)" onkeydown="this.value=this.value.substring(0, 200)" onkeyup="this.value=this.value.substring(0, 200)"    rows="3" placeholder="请输入文章描述信息/简介">{$info['describe']|default=''}</textarea>
            </div>
            <!--<div class="layui-form-mid layui-word-aux">-->
                <!--(文章描述信息/简介)-->
            <!--</div>-->
        </div>



        <div class="layui-form-item">
            <label for="logo" class="layui-form-label">
                <span class="x-red">*</span>封面图片（165*128）
            </label>
            <div id="logo" class="layui-input-block">
                {assign name="cover_id" value="$info.cover_id|default='0'" /}
                {:widget('file/index', ['name' => 'cover_id', 'value' => $cover_id, 'type' => 'img'])}
            </div>
            <!--<div class="layui-form-mid layui-word-aux">-->
                <!--(请上传单张封面图片)-->
            <!--</div>-->
        </div>
        <div class="layui-form-item">
            <label  class="layui-form-label">
                <span class="x-red">*</span>视频类型
            </label>
            <div class="layui-input-block">
                <select name="video_type" lay-filter="aihao">
                    <option value="2" {notempty name="info['video_type']"}{if condition="$info['video_type'] eq 2"} selected="selected" {/if}{/notempty} >超链接</option>
                    <option value="1" {notempty name="info['video_type']"}{if condition="$info['video_type'] eq 1"} selected="selected" {/if}{/notempty} >文件上传</option>

                </select>
            </div>
            <div class="layui-form-mid layui-word-aux">
                (视频类型)
            </div>

        </div>
        <div class="layui-form-item" id="video_url"  {if condition="isset($info) && $info['video_type'] eq 1"} style="display: none;{/if}>
            <label class="layui-form-label">
              视频超链接
            </label>
            <div class="layui-input-block">
                <input type="text" name="video_url"
                       autocomplete="text" class="layui-input"  value="{$info['video_url']|default=''}">
            </div>
            <div class="layui-form-mid layui-word-aux">
                (视频超链接)
            </div>
        </div>





        <div class="layui-form-item" id="video"  {if condition="isset($info) && $info['video_type'] eq 1"}{else/}style="display: none;"{/if}}>
            <label for="pid" class="layui-form-label">
              上传视频
            </label>
            <div class="layui-input-block">
                {assign name="file_id" value="$info.file_id|default='0'" /}
                {:widget('file/index', ['name' => 'file_id', 'value' => $file_id, 'type' => 'file'])}
            </div>
            <div class="layui-form-mid layui-word-aux">
                (上传视频)
            </div>

        </div>

        {if condition="$type eq 3"}
                <div class="layui-form-item">
                    <label for="pid" class="layui-form-label">
                        <span class="x-red">*</span>文章标签
                    </label>
                    <div class="layui-input-block">
                        <select name="level" >
                            {volist name='tag' id='vo'}
                            <option value="{$vo['id']}" {notempty name="$info['level']"}{if condition="$info['level'] eq $vo['id']"} selected="selected" {/if}{/notempty} >{$vo['name']}</option>
                            {/volist}
                        </select>
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        (文章标签)
                    </div>

                </div>

            <div class="layui-form-item">
                <label  class="layui-form-label">
                    <span class="x-red">*</span>视频分类
                </label>
                <div class="layui-input-block">
                    <select name="video_cate_id" >
                        {volist name='video_cate' id='vo'}
                        <option value="{$vo['id']}" {notempty name="$info['video_cate_id']"}{if condition="$info['video_cate_id'] eq $vo['id']"} selected="selected" {/if}{/notempty} >{$vo['name']}</option>
                        {/volist}
                    </select>
                </div>
                <div class="layui-form-mid layui-word-aux">
                    (视频分类)
                </div>

            </div>
        {/if}


        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>内容
            </label>
            <div class="layui-input-block">
                <textarea class="form-control textarea_editor" name="content" placeholder="请输入内容">{$info['content']|default=''}</textarea>
                {:widget('editor/index', array('name'=> 'content','value'=> ''))}
            </div>
        </div>



        <div class="box-footer">
            <input type="hidden" name="category_id" value="{$type}"/>
            <input type="hidden" name="id" value="{$info['id']|default='0'}"/>

            {include file="layout/edit_btn_group"/}

        </div>

    </form>
</div>

<script>
    layui.use('form', function(){
        var form = layui.form;

        form.on('select(aihao)', function(data){
            console.log(data.elem); //得到select原始DOM对象
            console.log(data.value); //得到被选中的值
            console.log(data.othis); //得到美化后的DOM对象
            if(data.value==1){
                $('#video_url').hide();
                $('#video').show();
            }else{
                $('#video_url').show();
                $('#video').hide();
            }

            form.render(null, 'form');
        });


    });


    function changevideo(v) {
        if(v==1){
            $('#video').show();
            $('#video_url').hide();
        }else{
            $('#video_url').show();
            $('#video').hide();
        }
    }
</script>
